Theme JSON: Fix handling of default presets at block level #10460
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Trac ticket: https://core.trac.wordpress.org/ticket/64195
This PR brings the changes from the following Gutenberg PRs to core:
WordPress/gutenberg#72916
Description
Prevents an issue where block level presets do not work correctly when:
The result is missing presets in the settings and editor UI.
Testing
For each theme.json example config below:
Duotone
In the image block, only the "Dark grayscale" duotone preset should be available
{ "version": 3, "appearanceTools": true, "settings": { "blocks":{ "core/image": { "color": { "defaultDuotone": false, "duotone": [ { "name": "Dark grayscale", "colors": [ "#000000", "#7f7f7f" ], "slug": "dark-grayscale" } ] } } } } }Shadow
In the image block, only the "Natural" shadow preset should be available
{ "version": 3, "settings": { "appearanceTools": true, "blocks":{ "core/image": { "shadow": { "defaultPresets": false, "presets": [ { "name": "Natural", "slug": "natural", "shadow": "6px 6px 9px rgba(0, 0, 0, 0.2)" } ] } } } } }Font Size
In the Paragraph block, only the "Small" duotone preset should be available
{ "version": 3, "settings": { "appearanceTools": true, "blocks":{ "core/paragraph": { "typography": { "defaultFontSizes": false, "fontSizes": [ { "name": "Small", "slug": "small", "size": "13px" } ] } } } } }Screenshots or screencast
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.